<?php

namespace app\controller;

use app\model\RepairModel;
use think\annotation\Route;
use think\Collection;
use think\response\Json;

class RepairController
{
    /**
     * @Route("insertRepairs")
     * @param $repairs
     * @param RepairModel $repairModel
     * @return int
     */
    public function insertRepairs($repairs, RepairModel $repairModel): int
    {
        return $repairModel->insertRepairs($repairs);
    }

    /**
     * @Route("deleteRepairs")
     * @param $ids
     * @param RepairModel $repairModel
     * @return Json
     */
    public function deleteRepairs($ids, RepairModel $repairModel): Json
    {
        return json(["result"=>$repairModel->deleteRepairs($ids)]);
    }

    /**
     * @Route("getAllRepairs")
     * @param RepairModel $repairModel
     * @return RepairModel[]|Collection
     */
    public function getAllRepairs(RepairModel $repairModel)
    {
        return $repairModel->getAllRepairs();
    }

    /**
     * @Route("updateRepairs")
     * @param $repairs
     * @param RepairModel $repairModel
     * @return Json
     */
    public function updateRepairs($repairs, RepairModel $repairModel): Json
    {
        $repairModel->updateRepairs($repairs);
        return json(["result"=>true]);
    }
}